package com.zgm.dao.impl;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.stereotype.Repository;

import com.zgm.dao.ProductDao;
import com.zgm.entity.Product;

@Repository
public class ProductDaoImpl extends BaseDaoImpl<Product, String> implements ProductDao {

//	@Override
//	public void merge(Product product) {
//		super.getSession().merge( product );
//	}
	
	/*@Resource
	private SessionFactory sessionFactory;
	
	public Product get(String id) {
		return ( Product ) this.getSession().get( Product.class, id );
	}
	
	public Session getSession() {
//		return this.sessionFactory.getCurrentSession();
		return this.sessionFactory.openSession();
		
		
	}
	
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public Product save(Product product) {
		Session session = this.getSession();
		Transaction transaction = session.beginTransaction();
		String id = ( String ) session.save( product );
		transaction.commit();
		return product;
		
	}

	public Product save2(Product product) {
		String id = ( String ) this.getSession2().save( product );
		return product;
	}

	private Session getSession2() {
		
		return this.sessionFactory.getCurrentSession();
	}*/

	

}
